package com.desire.homework;

import org.jsoup.Jsoup;

import java.util.Scanner;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

/**
 * @author desire
 */
public class _29_查询手机号归属地 {
    static Pattern pattern = Pattern.compile("<td><span>(.*)</span></td>");

    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        System.out.print("请输入手机号：");
        String tel = sc.nextLine();
        String url = String.format("https://ip138.com/mobile.asp?mobile=%s&action=mobile", tel);
        String html = Jsoup.connect(url).get().toString();
        Matcher matcher = pattern.matcher(html);
        while (matcher.find()) {
            System.out.print(matcher.group(1).replace("&nbsp;", " ") + " ");
        }

    }
}
